<?php

namespace addons\kuerp\model;

use think\Model;

/**
 *公告阅读记录
 */
class NoticeRead Extends Model {
    // 表名,不含前缀
    protected $name = 'kuerp_notice_read';
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';


    //添加阅读记录
    public static function addRead($notice_id, $admin_id) {
        return self::create([ 'notice_id' => $notice_id, 'admin_id' => $admin_id]);
    }


    //是否阅读
    public static function isRead($notice_id, $admin_id) {
        if (self::where(['notice_id' => $notice_id, 'admin_id' => $admin_id])->find()) {
            return 1;
        }

        return 0;
    }
}
